home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / graphics / avi2tga.zip / AVI2TGA.C next >
Text File  |  1994-02-22  |  2KB  |  58 lines

  1. /* This source code and it's executable carry no warranty of any form.
  2.     You execute the code at your own risk and should ensure that you have 
  3.     a backup of any disk that this may reside on.
  4.  
  5.     The code was developed (#define developed hacked) for a particular 
  6.     purpose and will only work for full frame 160*120*24 bit avi files.
  7. */
  8.  
  9. #include<stdio.h>
  10. main(int argc,char **argv)
  11. {
  12.     FILE *in,*out,*lst;
  13.     char tgaheader[]={0,0,0x2,0,0,0,0,0,0,0,0,0,0xa0,0,0x78,0,0x18,0};
  14.     char temp[59392];
  15.     char aviheader[2057];
  16.     char n[20],b[20],infile[20],outfile[20],lstfile[20];
  17.     int x,i,j,noframes;
  18.     printf("\aGraham's AVI (160*120*24bit full frame ONLY) to TGA convertor\n");
  19.     if (argc<4)
  20.     {
  21.      
  22.         printf("Usage:-\n");
  23.         printf("       avi2tga in out #frames format\n");
  24.         printf("  eg   avi2tga in test 150 %%02d\n");
  25.         printf("       will create 24 bit tga files called test01.tga to test150.tga\n");
  26.         printf("       and will create a file called out.lst containing a list of the\n");
  27.         printf("       files created suitable for feeding to CMPEG\n");      
  28.         printf("\nGraham Logan Febuary 1994\n");   
  29.         printf("graham@taurus.dct.ac.uk\n");
  30.         exit();
  31.     }
  32.     noframes=atoi(argv[3]);
  33.     strcpy(infile,argv[1]);
  34.     strcat(infile,".avi");
  35.     in=fopen(infile,"rb");
  36.     fread(aviheader,sizeof(char),2056,in);
  37.     strcpy(lstfile,argv[2]);
  38.     strcat(lstfile,".lst");
  39.     lst=fopen(lstfile,"w");
  40.  
  41.  
  42.     for (x=1;x<=noframes;x++)
  43.     {
  44.     strcpy(outfile,argv[2]);
  45.     sprintf(b,argv[4],x);
  46.     strcat(outfile,b);
  47.     strcat(outfile,".tga");
  48.     printf("%s frame %d -> %s\n",infile,x,outfile);
  49.     fprintf(lst,"%s\n",outfile);
  50.     out=fopen(outfile,"wb");
  51.  
  52.     fwrite(tgaheader,sizeof(char),18,out);
  53.     fread(temp,sizeof(char),59392,in);
  54.     fwrite(temp,sizeof(char),57600,out);
  55.     fclose(out);
  56.     }
  57. }
  58.